You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix constexpr constructors in dllimport classes [GH #583] - #584
default_ctor_can_be_constexpr rejected default constructors of dllimport classes with virtual functions too broadly. It rejected explicitly constexpr defaulted constructors and also suppressed implicit constexpr constructors in GNU and Clang emulation modes.
This change accepts explicitly declared constexpr constructors when they meet the usual requirements. It limits the existing restriction on implicitly generated constructors to Microsoft mode.
Coverage
Adds regression tests for direct and inherited virtual functions, a virtual destructor, and a default member initializer, plus a pending Changes entry.
Verification
Both regression tests pass with their recorded output in edg_x86_64 and edg_x86_64_cp.
Microsoft mode now accepts explicitly constexpr defaulted constructors in dllimport classes with virtual functions when they meet the usual constexpr requirements.
GNU and Clang emulation modes no longer let dllimport prevent an implicitly declared default constructor from being constexpr in classes with virtual functions.
No actionable comments were generated in the recent review.
Walkthrough
The compiler now applies the dllimport virtual-function restriction to implicitly constexpr default constructors only in Microsoft mode. Regression tests cover explicitly and implicitly constexpr constructors, and a pending-change note records the behavior across compiler modes.
The dllimport check now runs only in Microsoft mode and excludes constructors declared constexpr. Regression tests cover explicit and implicit default constructors with direct or inherited virtual functions, plus control cases. Expected outputs and the pending-change note record the tested diagnostics and mode behavior.
The change lets explicitly constexpr defaulted constructors in dllimport classes with virtual functions compile, and it keeps the old restriction for implicitly generated constructors in Microsoft mode. Regression tests and a pending-change note are included, and no merge-blocking issue was found.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "Fix constexpr constructors in dllimport classes [GH #583]" names the main change. The objectives say the PR narrows the default_ctor_can_be_constexpr restriction so explicitly constexpr def…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "Fix constexpr constructors in dllimport classes [GH #583]" names the main change. The objectives say the PR narrows the default_ctor_can_be_constexpr restriction so explicitly constexpr defaulted constructors in dllimport classes with virtual functions are accepted, while the implicit-constructor limit applies only in Microsoft mode. The changeset (src/class_decl.c, the pending-change note for GH #583, and the regression tests for dllimport constexpr defaulted and implicit default constructors) matches this. The title is specific and concise, and the issue tag helps scanning.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
default_ctor_can_be_constexpr rejected default constructors of dllimport classes with virtual functions too broadly. It rejected explicitly constexpr defaulted constructors and also suppressed implicit constexpr constructors in GNU and Clang emulation modes.
This change accepts explicitly declared constexpr constructors when they meet the usual requirements. It limits the existing restriction on implicitly generated constructors to Microsoft mode.
Coverage
Adds regression tests for direct and inherited virtual functions, a virtual destructor, and a default member initializer, plus a pending Changes entry.
Verification
Related discussion: #583
Summary by CodeRabbit
constexprdefaulted constructors indllimportclasses with virtual functions when they meet the usualconstexprrequirements.dllimportprevent an implicitly declared default constructor from beingconstexprin classes with virtual functions.